package com.sgb.contract.view.widget.pop;

import android.content.Context;
import android.os.Build;
import android.text.Html;
import android.view.View;
import android.widget.TextView;

import com.sgb.contract.R;
import com.sgb.contract.model.UpdateBean;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;

import androidx.annotation.RequiresApi;

/**
 * 作者:张磊
 * 日期:2021/4/16 0016
 * 说明:数据集合
 */
public class DataDetailedPop extends BasePopWindow {

    private TextView mTvContent;
    private View mNsv;
    private View mLlShow;
    private TextView mTvFirst;
    private TextView mTvSecond;

    public DataDetailedPop(Context context) {
        super(context, DIR_DOWN_UP);
    }

    @Override
    protected int popLayout() {
        return R.layout.contract_datadetailed_pop;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        mTvContent = holder.getPop().findViewById(R.id.tv_content);
        mNsv = holder.getPop().findViewById(R.id.nsv);
        mLlShow = holder.getPop().findViewById(R.id.ll_show);
        mTvFirst = holder.getPop().findViewById(R.id.tv_first);
        mTvSecond = holder.getPop().findViewById(R.id.tv_second);
        holder.getPop().findViewById(R.id.tv_cancel).setOnClickListener(v -> dismiss());
    }

    @RequiresApi(api = Build.VERSION_CODES.N)
    public void show(View view, UpdateBean bean) {
        if (bean.changeCompanyNameList != null && bean.changeCompanyNameList.size() > 1) {
            mNsv.setVisibility(View.GONE);
            mLlShow.setVisibility(View.VISIBLE);
            mTvFirst.setText(bean.changeCompanyNameList.get(0));
            mTvSecond.setText(bean.changeCompanyNameList.get(1));
        } else {
            mNsv.setVisibility(View.VISIBLE);
            mLlShow.setVisibility(View.GONE);
            mTvContent.setText(Html.fromHtml(bean.originalContent, Html.FROM_HTML_MODE_LEGACY));
        }
        showPopwindowBottom(view);
    }
}